<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.16: http://docutils.sourceforge.net/" />
<title>note.20ww37d316_3cd2b5b5.rst</title>
<style type="text/css">


/*
 * CSS hacks and small modification for my Sphinx website
 * :copyright: Copyright 2013-2016 Lilian Besson
 * :license: GPLv3, see LICENSE for details.
 */


/* Colors and text decoration.
 For example, :black:`text in black` or :blink:`text blinking` in rST. */

.black {
    color: black;
}

.gray {
    color: gray;
}

.grey {
    color: gray;
}

.silver {
    color: silver;
}

.white {
    color: white;
}

.maroon {
    color: maroon;
}

.red {
    color: red;
}

.magenta {
    color: magenta;
}

.fuchsia {
    color: fuchsia;
}

.pink {
    color: pink;
}

.orange {
    color: orange;
}

.yellow {
    color: yellow;
}

.lime {
    color: lime;
}

.redbig {
    color: #530000;
    background-color: #ffb5b5;
    font-weight: bold;
    font-family: "Courier New", monospace;
}

.bluebig {
    color: #000053;
    background-color: #b5b5ff;
    font-weight: bold;
    font-family: "Courier New", monospace;
}

.bluenormal {
    color: #000053;
    background-color: #b5b5ff;
    font-family: "Courier New", monospace;
}

.greybig {
    color: #0a0a0a;
    background-color: #b5b5b5;
    font-weight: bold;
    font-family: "Courier New", monospace;
}

.smallcourier {
    font-size: small;
    font-family: "Courier New", monospace;
}


.greenbig {
    color: #004500;
    background-color: #a7ffa7;
    font-weight: bold;
    font-family: "Courier New", monospace;
}


.green {
    color: green;
}

.olive {
    color: olive;
}

.teal {
    color: teal;
}

.cyan {
    color: cyan;
}

.aqua {
    color: aqua;
}

.blue {
    color: blue;
}

.navy {
    color: navy;
}

.purple {
    color: purple;
}

.under {
    text-decoration: underline;
}

.over {
    text-decoration: overline;
}

.blink {
    text-decoration: blink;
}

.line {
    text-decoration: line-through;
}

.strike {
    text-decoration: line-through;
}

.it {
    font-style: italic;
}

.ob {
    font-style: oblique;
}

.small {
    font-size: small;
}

.large {
    font-size: large;
}

.smallpar {
    font-size: small;
}


/* Style pour les badges en bas de la page. */

div.supportBadges {
    margin: 1em;
    text-align: right;
}

div.supportBadges ul {
    padding: 0;
    display: inline;
}

div.supportBadges li {
    display: inline;
}

div.supportBadges a {
    margin-right: 1px;
    opacity: 0.6;
}

div.supportBadges a:hover {
    opacity: 1;
}


/* Details elements in the sidebar */

a.reference {
    border-bottom: none;
    text-decoration: none;
}

ul.details {
    font-size: 80%;
}

ul.details li p {
    font-size: 85%;
}

ul.externallinks {
    font-size: 85%;
}


/* Pour le drapeau de langue */

img.languageswitch {
    width: 50px;
    height: 32px;
    margin-left: 5px;
    vertical-align: bottom;
}

div.sphinxsidebar {
    overflow: hidden !important;
    font-size: 120%;
    word-wrap: break-word;
    width: 300px;
    max-width: 300px;
}

div.sphinxsidebar h3 {
    font-size: 125%;
}

div.sphinxsidebar h4 {
    font-size: 110%;
}

div.sphinxsidebar a {
    font-size: 85%;
}


/* Image style for scrollUp jQuery plugin */

#scrollUpLeft {
    bottom: 50px;
    left: 260px;
    height: 38px;
    width: 38px;
    background: url('//perso.crans.org/besson/_images/.top.svg');
    background: url('../_images/.top.svg');
}

@media screen and (max-width: 875px) {
    #scrollUpLeft {
        right: 50px;
        left: auto;
    }
}


/* responsive for font-size. */

@media (max-width: 875px) {
    body {
        font-size: 105%;
        /* Increase font size for responsive theme */
    }
}

@media (max-width: 1480px) and (min-width: 876px) {
    body {
        font-size: 110%;
        /* Increase font size for not-so-big screens */
    }
}

@media (min-width: 1481px) {
    body {
        font-size: 115%;
        /* Increase even more font size for big screens */
    }
}


/* Social Icons in the sidebar (available: twitter, facebook, linkedin, google+, bitbucket, github) */

.social-icons {
    display: inline-block;
    margin: 0;
    text-align: center;
}

.social-icons a {
    background: none no-repeat scroll center top #444444;
    border: 1px solid #F6F6F6;
    border-radius: 50% 50% 50% 50%;
    display: inline-block;
    height: 35px;
    width: 35px;
    margin: 0;
    text-indent: -9000px;
    transition: all 0.2s ease 0s;
    text-align: center;
    border-bottom: none;
}

.social-icons li {
    display: inline-block;
    list-style-type: none;
    border-bottom: none;
}
.social-icons li a {
    border-bottom: none;
}

.social-icons a:hover {
    background-color: #666666;
    transition: all 0.2s ease 0s;
    text-decoration: none;
}

.social-icons a.facebook {
    background-image: url('../_images/.facebook.png');
    background-image: url('//perso.crans.org/besson/_images/.facebook.png');
    display: block;
    margin-left: auto;
    margin-right: auto;
    background-size: 35px 35px;
}

.social-icons a.bitbucket {
    background-image: url('../_images/.bitbucket.png');
    background-image: url('//perso.crans.org/besson/_images/.bitbucket.png');
    display: block;
    margin-left: auto;
    margin-right: auto;
    background-size: 35px 35px;
}

.social-icons li a.github {
    background-image: url('../_images/.github.png');
    background-image: url('//perso.crans.org/besson/_images/.github.png');
    display: block;
    margin-left: auto;
    margin-right: auto;
    background-size: 35px 35px;
}

.social-icons li a.wikipedia {
    background-image: url('../_images/.wikipedia.png');
    background-image: url('//perso.crans.org/besson/_images/.wikipedia.png');
    display: block;
    margin-left: auto;
    margin-right: auto;
    background-size: 35px 35px;
}


</style>
<style type="text/css">

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.

See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
  border: 0 }

table.borderless td, table.borderless th {
  /* Override padding for "table.docutils td" with "! important".
     The right padding separates the table cells. */
  padding: 0 0.5em 0 0 ! important }

.first {
  /* Override more specific margin styles with "! important". */
  margin-top: 0 ! important }

.last, .with-subtitle {
  margin-bottom: 0 ! important }

.hidden {
  display: none }

.subscript {
  vertical-align: sub;
  font-size: smaller }

.superscript {
  vertical-align: super;
  font-size: smaller }

a.toc-backref {
  text-decoration: none ;
  color: black }

blockquote.epigraph {
  margin: 2em 5em ; }

dl.docutils dd {
  margin-bottom: 0.5em }

object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
  overflow: hidden;
}

/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
  font-weight: bold }
*/

div.abstract {
  margin: 2em 5em }

div.abstract p.topic-title {
  font-weight: bold ;
  text-align: center }

div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
  margin: 2em ;
  border: medium outset ;
  padding: 1em }

div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
  font-weight: bold ;
  font-family: sans-serif }

div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
  color: red ;
  font-weight: bold ;
  font-family: sans-serif }

/* Uncomment (and remove this text!) to get reduced vertical space in
   compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
  margin-bottom: 0.5em }

div.compound .compound-last, div.compound .compound-middle {
  margin-top: 0.5em }
*/

div.dedication {
  margin: 2em 5em ;
  text-align: center ;
  font-style: italic }

div.dedication p.topic-title {
  font-weight: bold ;
  font-style: normal }

div.figure {
  margin-left: 2em ;
  margin-right: 2em }

div.footer, div.header {
  clear: both;
  font-size: smaller }

div.line-block {
  display: block ;
  margin-top: 1em ;
  margin-bottom: 1em }

div.line-block div.line-block {
  margin-top: 0 ;
  margin-bottom: 0 ;
  margin-left: 1.5em }

div.sidebar {
  margin: 0 0 0.5em 1em ;
  border: medium outset ;
  padding: 1em ;
  background-color: #ffffee ;
  width: 40% ;
  float: right ;
  clear: right }

div.sidebar p.rubric {
  font-family: sans-serif ;
  font-size: medium }

div.system-messages {
  margin: 5em }

div.system-messages h1 {
  color: red }

div.system-message {
  border: medium outset ;
  padding: 1em }

div.system-message p.system-message-title {
  color: red ;
  font-weight: bold }

div.topic {
  margin: 2em }

h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
  margin-top: 0.4em }

h1.title {
  text-align: center }

h2.subtitle {
  text-align: center }

hr.docutils {
  width: 75% }

img.align-left, .figure.align-left, object.align-left, table.align-left {
  clear: left ;
  float: left ;
  margin-right: 1em }

img.align-right, .figure.align-right, object.align-right, table.align-right {
  clear: right ;
  float: right ;
  margin-left: 1em }

img.align-center, .figure.align-center, object.align-center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

table.align-center {
  margin-left: auto;
  margin-right: auto;
}

.align-left {
  text-align: left }

.align-center {
  clear: both ;
  text-align: center }

.align-right {
  text-align: right }

/* reset inner alignment in figures */
div.align-right {
  text-align: inherit }

/* div.align-center * { */
/*   text-align: left } */

.align-top    {
  vertical-align: top }

.align-middle {
  vertical-align: middle }

.align-bottom {
  vertical-align: bottom }

ol.simple, ul.simple {
  margin-bottom: 1em }

ol.arabic {
  list-style: decimal }

ol.loweralpha {
  list-style: lower-alpha }

ol.upperalpha {
  list-style: upper-alpha }

ol.lowerroman {
  list-style: lower-roman }

ol.upperroman {
  list-style: upper-roman }

p.attribution {
  text-align: right ;
  margin-left: 50% }

p.caption {
  font-style: italic }

p.credits {
  font-style: italic ;
  font-size: smaller }

p.label {
  white-space: nowrap }

p.rubric {
  font-weight: bold ;
  font-size: larger ;
  color: maroon ;
  text-align: center }

p.sidebar-title {
  font-family: sans-serif ;
  font-weight: bold ;
  font-size: larger }

p.sidebar-subtitle {
  font-family: sans-serif ;
  font-weight: bold }

p.topic-title {
  font-weight: bold }

pre.address {
  margin-bottom: 0 ;
  margin-top: 0 ;
  font: inherit }

pre.literal-block, pre.doctest-block, pre.math, pre.code {
  margin-left: 2em ;
  margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}

span.classifier {
  font-family: sans-serif ;
  font-style: oblique }

span.classifier-delimiter {
  font-family: sans-serif ;
  font-weight: bold }

span.interpreted {
  font-family: sans-serif }

span.option {
  white-space: nowrap }

span.pre {
  white-space: pre }

span.problematic {
  color: red }

span.section-subtitle {
  /* font-size relative to parent (h1..h6 element) */
  font-size: 80% }

table.citation {
  border-left: solid 1px gray;
  margin-left: 1px }

table.docinfo {
  margin: 2em 4em }

table.docutils {
  margin-top: 0.5em ;
  margin-bottom: 0.5em }

table.footnote {
  border-left: solid 1px black;
  margin-left: 1px }

table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
  padding-left: 0.5em ;
  padding-right: 0.5em ;
  vertical-align: top }

table.docutils th.field-name, table.docinfo th.docinfo-name {
  font-weight: bold ;
  text-align: left ;
  white-space: nowrap ;
  padding-left: 0 }

/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
  border: 0px;
  border-top: 2px solid;
  border-bottom: 2px solid;
  border-collapse: collapse;
}
table.docutils.booktabs * {
  border: 0px;
}
table.docutils.booktabs th {
  border-bottom: thin solid;
  text-align: left;
}

h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
  font-size: 100% }

ul.auto-toc {
  list-style-type: none }

</style>
</head>
<body>
<div class="document">


<!-- Color profiles for Sphinx. -->
<!-- Has to be used with hacks.css (bitbucket.org/lbesson/web-sphinx/src/master/.static/hacks.css) -->
<div class="contents topic" id="automation-notes">
<p class="topic-title">automation notes</p>
<ul class="simple">
<li><a class="reference internal" href="#to-find-file-based-on-ignoring-case-filenames" id="id6">to find file, based on (ignoring case) filenames</a><ul>
<li><a class="reference internal" href="#usage-ff" id="id7">Usage, ff</a></li>
<li><a class="reference internal" href="#usage-ff1" id="id8">Usage, ff1</a></li>
</ul>
</li>
<li><a class="reference internal" href="#to-find-file-names-not-matching-some-string-keyword-patterns" id="id9">to find file names, __NOT__ matching some string (keyword) patterns</a></li>
<li><a class="reference internal" href="#to-know-the-absolute-path-of-a-file" id="id10">to know the absolute path of a file;</a></li>
<li><a class="reference internal" href="#zck-to-grep-for-multi-strings-in-all-files-below-current-directory" id="id11">zck, to 'grep' for multi-strings in __ALL__ files below current directory</a><ul>
<li><a class="reference internal" href="#limits-of-ack-grep" id="id12">Limits of ack/grep</a></li>
<li><a class="reference internal" href="#remedy-zck-alias-command-or-zck-pl-a-file" id="id13">Remedy: zck (alias command) or zck.pl (a file)</a><ul>
<li><a class="reference internal" href="#zck-an-alias-command" id="id14">zck (an alias command)</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#very-long-string-diff-strdiff" id="id15">(Very Long) String-Diff (strdiff)</a><ul>
<li><a class="reference internal" href="#installation-strdiff" id="id16">Installation, strdiff</a></li>
<li><a class="reference internal" href="#usage-strdiff" id="id17">Usage, strdiff</a></li>
</ul>
</li>
<li><a class="reference internal" href="#multi-string-highlighting-hh" id="id18">multi-string highlighting, hh</a><ul>
<li><a class="reference internal" href="#installation-hh" id="id19">Installation, hh</a></li>
<li><a class="reference internal" href="#usage-hh" id="id20">Usage, hh</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="to-find-file-based-on-ignoring-case-filenames">
<h1><a class="toc-backref" href="#id6">to find file, based on (ignoring case) filenames</a></h1>
<p>to look for files of which filenames match sub-strings (in any order), <em>IGNORING CASES</em>.</p>
<p>Please include this line into ~/.aliases  (assuming <tt class="docutils literal"><span class="pre">~/.cshrc.$USER</span></tt> mentions to source <tt class="docutils literal"><span class="pre">~/.aliases</span></tt> ).</p>
<pre class="literal-block">
alias ff '/usr/bin/perl -Mfeature=say -e '\'' \\
my &#64;A   = qw(\!*);\\
my $dir = ( shift &#64;A ) // &quot;.&quot;;\\
my $s0  = qq/find $dir /;\\
map { $s0 .= ( $_ =~ m/^\./ ) ? qq/ -not/ : qq/ /; $_ =~ s/^\.//; $s0 .= qq/ -iname &quot;*$_*&quot;/; } &#64;A;\\
$s0 .= qq{ -printf \&quot;%-30p    size_%kk    --%Cc--\\n\&quot; };\\
say $s0; say;\\
system $s0;\\
say; say; say $s0; say q/done/; '\'


alias ff1 '/usr/bin/perl -Mfeature=say -e '\'' \\
my &#64;A   = qw(\!*);\\
my $dir = ( shift &#64;A ) // &quot;.&quot;;\\
my $s0  = qq/find $dir -maxdepth 1 /;\\
map { $s0 .= ( $_ =~ m/^\./ ) ? qq/ -not/ : qq/ /; $_ =~ s/^\.//; $s0 .= qq/ -iname &quot;*$_*&quot;/; } &#64;A;\\
$s0 .= qq{ -printf \&quot;%-30p    size_%kk    --%Cc--\\n\&quot; };\\
say $s0; say;\\
system $s0;\\
say; say; say $s0; say q/done/; '\'
</pre>
<table class="docutils footnote" frame="void" id="id1" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id2">[1]</a></td><td>Minor details about difference between ff-in-aliases versus ff-in-home-bin: ff command inside aliases, would force c-shell to load the whole one-liner command into memory.  In contrast, ~/bin/ff inside the search-path, would require c-shell to look up the ff file, then execute this found file.  Run-time wise, alias approach is usually faster. Historically there is a limit on memory used by aliases commands.  In present time, we should not suffer from such limit.</td></tr>
</tbody>
</table>
<div class="section" id="usage-ff">
<h2><a class="toc-backref" href="#id7">Usage, ff</a></h2>
<p>Please do:</p>
<pre class="literal-block">
ff &lt;directory&gt; &lt;str1&gt; &lt;str2&gt; &lt;str3&gt;
</pre>
<p>e.g.,:</p>
<pre class="literal-block">
ff . rpt ap adr
</pre>
<p>above command translates sub-strings into <span class="redbig">find</span>
command's <tt class="docutils literal"><span class="pre">-iname</span></tt> arguments. Since all <tt class="docutils literal"><span class="pre">-iname</span></tt> arguments
are joined with <em>AND</em> condition, the found file's names
will match <em>ALL</em> sub-strings <span class="under">in any order</span>.</p>
<pre class="literal-block">
find . -iname &quot;*rpt*&quot; -iname &quot;*ap*&quot; -iname &quot;*adr*&quot; -printf '%-30p size_%kk --%Cc--\n'
</pre>
<p>result looks like</p>
<pre class="literal-block">
./ap95a8d0ea82.adr.45c2728081.rpt    size_332k    --Tue 07 Jul 2015 12:26:23 PM PDT--
</pre>
<p>The <tt class="docutils literal"><span class="pre">-printf</span></tt> argument is from author's personal
preference. In short, it first shows the filesize in
kbytes (<tt class="docutils literal">size_%kk</tt>). Then the specific timestamp with
weekday and seconds (<tt class="docutils literal"><span class="pre">--%Cc--</span></tt>). <span class="greybig">Please</span>
feel free to modify <tt class="docutils literal"><span class="pre">-printf</span></tt> arguments; see
<tt class="docutils literal">man find</tt> page (search for <tt class="docutils literal">%Ak</tt>) for details.</p>
</div>
<div class="section" id="usage-ff1">
<h2><a class="toc-backref" href="#id8">Usage, ff1</a></h2>
<p>Like the <tt class="docutils literal">ff</tt> command, this <tt class="docutils literal">ff1</tt> command <em>ONLY</em> search
in current directory (not going below sub-dir). Namely,
it's providing <tt class="docutils literal"><span class="pre">-maxdepth</span> 1</tt> argument for find command.</p>
<pre class="literal-block">
ff1 &lt;directory&gt; &lt;str1&gt; &lt;str2&gt; &lt;str3&gt;
</pre>
<p>Will be translated into <span class="greybig">find . -maxdepth 1</span> ... command.</p>
</div>
</div>
<div class="section" id="to-find-file-names-not-matching-some-string-keyword-patterns">
<h1><a class="toc-backref" href="#id9">to find file names, __NOT__ matching some string (keyword) patterns</a></h1>
<p>Now, to find file names <em>NOT</em> matching strings with by prepending a dot <span class="greybig">'.'</span> character, such as:</p>
<pre class="literal-block">
ff &lt;directory&gt; .str1 .str2 .str3
</pre>
<p>It is translated into below find command, with -not arguments.  Like:</p>
<pre class="literal-block">
find .    -not -iname &quot;*str1*&quot;   -not -iname &quot;*str2*&quot;   -not -iname &quot;*str3*&quot;
</pre>
<p>Same behavior can be found with ff1 command (to only search whithin the directory, not descending into sub-dir):</p>
<pre class="literal-block">
ff1 &lt;directory&gt; .str1 .str2 .str3
</pre>
</div>
<hr class="docutils" />
<div class="section" id="to-know-the-absolute-path-of-a-file">
<h1><a class="toc-backref" href="#id10">to know the absolute path of a file;</a></h1>
<p>use command &quot;realpath&quot;.  but you can also alias it with shorter command, like below.  (put below into ~/.aliases):</p>
<pre class="literal-block">
alias rp   '/usr/bin/realpath \!*'
</pre>
<p>then command <span class="greybig">rp fileA</span> would give you absolute path of <tt class="docutils literal">fileA</tt>.</p>
</div>
<div class="section" id="zck-to-grep-for-multi-strings-in-all-files-below-current-directory">
<h1><a class="toc-backref" href="#id11">zck, to 'grep' for multi-strings in __ALL__ files below current directory</a></h1>
<blockquote>
this command greps for all files downward current directory.
The output format is preferrable to <tt class="docutils literal">grep <span class="pre">-r</span> &lt;string&gt;</tt> (recursively into
sub-directories).</blockquote>
<p><span class="greybig">ack -i &lt;string&gt;</span></p>
<blockquote>
should return something (in better format, with filename, line
number and color highlighting matched strings) <a class="footnote-reference" href="#id1" id="id2">[1]</a>.</blockquote>
<pre class="literal-block">
%ack -i abs
sf_hack.pl
16:use Cwd 'abs_path';
17:#my $abs_path = abs_path($file);
</pre>
<table class="docutils footnote" frame="void" id="id3" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id4">[2]</a></td><td>above <tt class="docutils literal">sf_hack.pl</tt> is the file name and line 16-17 matches the keyword &quot;abs&quot;.</td></tr>
</tbody>
</table>
<p>It is optional to alias it as default behavior, like (in <tt class="docutils literal"><span class="pre">~/.aliases</span></tt> file)</p>
<pre class="literal-block">
alias ack 'ack -i'
</pre>
<p>Likewise, below is  author's default grep command; put it into <tt class="docutils literal"><span class="pre">~/.aliases</span></tt>.</p>
<pre class="literal-block">
alias grep 'grep -i --color '
</pre>
<p>In fact, we can use <tt class="docutils literal">grep</tt> command to approximate <tt class="docutils literal">ack</tt>'s
behavior. (Please spend some time reading <tt class="docutils literal">&quot;man grep&quot;</tt> page) <a class="footnote-reference" href="#id3" id="id4">[2]</a>.</p>
<p><span class="greybig">grep -nHir &quot;confirmation_dialog&quot; .</span></p>
<table class="docutils footnote" frame="void" id="id5" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[3]</td><td>the final dot &quot;.&quot; means current directory.</td></tr>
</tbody>
</table>
<div class="section" id="limits-of-ack-grep">
<h2><a class="toc-backref" href="#id12">Limits of ack/grep</a></h2>
<p>Neither <span class="greybig">ack</span> command or <span class="greybig">grep</span>
command works on zipped files. (This is the reason
why command <span class="greybig">zgrep/gzgrep/bzgrep</span> exists).</p>
</div>
<div class="section" id="remedy-zck-alias-command-or-zck-pl-a-file">
<h2><a class="toc-backref" href="#id13">Remedy: zck (alias command) or zck.pl (a file)</a></h2>
<p>This tool is probably the most powerful and handy grepping tool developed by the author.</p>
<div class="section" id="zck-an-alias-command">
<h3><a class="toc-backref" href="#id14">zck (an alias command)</a></h3>
<p>Tool <tt class="docutils literal">zck</tt> usage can take in multiple string patterns
(like <tt class="docutils literal">str1 str3 str2</tt> etc); any text line consisting
all of <tt class="docutils literal">str1 str2 str3</tt> strings <span class="under">IN ANY ORDER</span>,
will be found (e.g., <span class="greybig">str3---str1---str2</span> or
<span class="greybig">str2---str1---str3</span>, etc)</p>
<p>(The name <span class="greybig">zck</span> is to show respect to command <tt class="docutils literal">ack</tt>, while the <span class="greybig">z</span> character shows the applicable-ness to zipped files)</p>
<p>All string patterns' upper or lower cases will be ignored.
Also, <span class="greybig">zck</span> will try to match file names too. (file name
matching all <tt class="docutils literal">str1, str2 and str3</tt> would be hilighted in
color).</p>
<p>Installation: please insert below 50+ lines of text into <span class="greybig">~/.aliases</span>.:</p>
<pre class="literal-block">
alias zck '/usr/bin/perl -MCarp -MCwd=abs_path -MFile::Find -MTerm::ANSIColor -Mfeature=say -e '\''\\
BEGIN {\\
    $|=1;\\
    &#64;Afg = qw( underline_green underline_yellow underline_bold_blue underline_magenta \\
    underline_cyan underline_red bold_green bold_yellow bold_blue bold_magenta bold_cyan bold_red); \\
    map { s/_/ /g } &#64;Afg;\\
\\
    sub CoN {\\
        my ( $pat, $it ) = &#64;_;\\
        $it = $it // 1;\\
        my $it2 = ( int $it ) % ( $#Afg + 1 );\\
        if ( -t STDOUT ) { return colored( $pat, $Afg[$it2], q/on_black/ ); }\\
        else             { return $pat; }\\
    }\\
}\\
push &#64;Adir, Cwd::getcwd();\\
&#64;Apat = split /\s+/, &quot;\!:*&quot;;\\
(&#64;Apat) or  Carp::confess &quot;-e- please provide string patterns&quot;;\\
$sPat=join &quot;, &quot;, &#64;Apat;\\
printf( &quot;%s %8s %s\n&quot;, &quot;-I-&quot; , &amp;CoN(&quot;Looking for strings &quot;, 6), &amp;CoN(qq/&quot;$sPat&quot;/, 7));\\
&amp;find(\&amp;wanted, &#64;Adir);\\
sub wanted \\
{\\
    my $FName = $_;\\
    if ( -f $FName ) {\\
        my $FileNameMatched = 1;\\
        foreach my $pat (&#64;Apat) {\\
            $FileNameMatched &amp;= ( $FName =~ m/$pat/i );\\
            if ( not $FileNameMatched ) { last; }\\
        }\\
        if ($FileNameMatched) { printf  &quot;%s %s/%s \n&quot;, &quot;filname matched::&quot;, $File::Find::dir, &amp;CoN( $FName ); }\\
        my $FHandle;\\
        if    (m/\.gz$/i)  { $FHandle = &quot;gzcat $FName |&quot;; }\\
        elsif (m/\.bz2$/i) { $FHandle = &quot;bzcat $FName |&quot;; }\\
        else              { $FHandle = &quot;cat $FName |&quot;; }\\
        foreach my $pat (&#64;Apat) { $FHandle .= &quot; grep -iF $pat | &quot;; }\\
        my $NSH;\\
        open $NSH, $FHandle;\\
        my &#64;A1 = &lt;$NSH&gt;;\\
        close $NSH;\\
        if (&#64;A1) {\\
        my $str1 = join &quot;&quot;, &#64;A1;\\
            my $i3 = 0;\\
            foreach my $pat (&#64;Apat) {\\
                $str1 =~ s#($pat)# &amp;CoN($1, $i3)  #sixge;\\
                $i3++;\\
            }\\
            my $strFN2 = $File::Find::name;\\
            $strFN2 =~ s#(.*?)([^ \/]+)$#&amp;CoN($1, 8) .&amp;CoN($2, 9)  #sixe;\\
            printf &quot;\n-i- %s %s \n&quot;, &quot;FOUND IN: &quot;, $strFN2;\\
            print $str1;\\
            say &quot;-&quot; x 80;\\
        }\\
    }\\
}\\
'\'
</pre>
<hr class="docutils" />
<p>Usage: assuming to look for a line of text matching _ALL_ of <span class="greybig">string1</span>, <span class="greybig">string2</span>,  and <span class="greybig">string3</span>.:</p>
<pre class="literal-block">
zck string1 string2 string3
</pre>
<p>And output would be like</p>
<blockquote>
<p>-i- FOUND IN:  /SomeDir/cfg/<span class="bluebig">file.init</span></p>
<p>info exists GLOBS(<span class="redbig">str1</span> _SomeOtherText1_ <span class="greenbig">str2</span>) ] &amp;&amp; $GLOBS(<span class="redbig">str1</span> _SomeOtherText2_ <span class="greenbig">str2</span>) == &quot;1&quot;</p>
</blockquote>
<hr class="docutils" />
<p>One more step into efficiency:
pipe the results into vim buffer, like</p>
<pre class="literal-block">
zck str1 str2 |&amp; gvim -R -
</pre>
<p>Explanation:</p>
<ul class="simple">
<li><tt class="docutils literal">&quot;gvim - &quot;</tt> would take content from stdin (stream from pipe)</li>
<li><tt class="docutils literal">&quot;gvim <span class="pre">-R&quot;</span></tt> would treat the vim buffer (aka session) read-only;</li>
<li>so when we close this gvim buffer, there is no warning-on-modfied.</li>
</ul>
</div>
</div>
</div>
<div class="section" id="very-long-string-diff-strdiff">
<h1><a class="toc-backref" href="#id15">(Very Long) String-Diff (strdiff)</a></h1>
<p>At work we encounter situations of multi-hierarchy multi-instance designs, such as <tt class="docutils literal">hierA1/hierA1/hierB2/hierC3/hierD4/blockE5%signalF6</tt>.
Human eyes cannot remember so many details; errors and confusion and arguing would occur.
In answering the question &quot;what difference is between these two pins?&quot;, we need a string-differentiating tool.</p>
<p>Below alias command uses perl module <tt class="docutils literal"><span class="pre">Algorithm::Diff</span></tt>;
it tries to match the <span class="under">longest common subsequence</span> (LCS) in
the two strings.  LCS is a classical NP-hard computer science problem.  Thus most of tools can only achieve &quot;good enough&quot; solution.
For our work, it should be also &quot;good enough&quot;.</p>
<div class="section" id="installation-strdiff">
<h2><a class="toc-backref" href="#id16">Installation, strdiff</a></h2>
<p>Please inject this whole text into <tt class="docutils literal"><span class="pre">~/.aliases</span></tt> file and do `` source ~/.aliases``.</p>
<pre class="literal-block">
alias strdiff '/usr/bin/perl -MAlgorithm::Diff=sdiff -MTerm::ANSIColor -Mfeature=say -e '\'' \\
my $st1    = &quot;\!:1&quot;;\\
my $st2    = &quot;\!:2&quot;;\\
my $stdiff = StringDiff( $st1, $st2 );\\
say $stdiff;\\
\\
sub StringDiff {\\
    my ( $s1, $s2 ) = &#64;_;\\
    if ( not $s1 or not $s2 ) { return undef; }\\
    my &#64;A1 = ( $s1 =~ m#(.)#g );\\
    my &#64;A2 = ( $s2 =~ m#(.)#g );\\
    my &#64;A3 = sdiff( \&#64;A1, \&#64;A2 );\\
    foreach my $i (&#64;A3) {\\
        my $k0 = ( $i-&gt;[0] =~ s#u# #ir );\\
        $k0 =~ s#-#v#;\\
        $k0 =~ s#\+#^#;\\
        $k0 =~ s#c#-#;\\
        if ( -t STDOUT ) { push &#64;B0, colored( $k0, q/bold red/, q/on_black/ ); }\\
        else             { push &#64;B0, $k0; }\\
        if   ( $i-&gt;[1] =~ m#\S# ) { push &#64;B1, $i-&gt;[1]; }\\
        else                      { push &#64;B1, q/ /; }\\
        if   ( $i-&gt;[2] =~ m#\S# ) { push &#64;B2, $i-&gt;[2]; }\\
        else                      { push &#64;B2, q/ /; }\\
    }\\
    my $stb0 = join &quot;&quot;,   &#64;B0;\\
    my $stb1 = join &quot;&quot;,   &#64;B1;\\
    my $stb2 = join &quot;&quot;,   &#64;B2;\\
    my $st5  = join &quot;\n&quot;, q##, $stb1, $stb0, $stb2;\\
    return $st5;\\
}\\
'\'
</pre>
</div>
<div class="section" id="usage-strdiff">
<h2><a class="toc-backref" href="#id17">Usage, strdiff</a></h2>
<p>As in above picture, please do <tt class="docutils literal">&quot;strdiff stringA stringB&quot;</tt> at terminal.</p>
</div>
</div>
<div class="section" id="multi-string-highlighting-hh">
<h1><a class="toc-backref" href="#id18">multi-string highlighting, hh</a></h1>
<p>Command <tt class="docutils literal">&quot;grep <span class="pre">--color</span> &quot;</tt> can highlight matched strings in (red) color. But it is only <span class="under">one color</span> when we try to match multiple strings, as in
<tt class="docutils literal">&quot;grep <span class="pre">--color</span> <span class="pre">-ie</span> string1 <span class="pre">-ie</span> string2 &quot;</tt>.
Again, in multi-hierarchy, multi-instance design, we need to highlight strings in :<span class="under">different colors</span>.
Therefore, we developed this tool, <tt class="docutils literal">hh</tt> highlighter.</p>
<div class="section" id="installation-hh">
<h2><a class="toc-backref" href="#id19">Installation, hh</a></h2>
<pre class="literal-block">
alias hh '/usr/bin/perl -MTerm::ANSIColor -pe '\'' \\
BEGIN {\\
    $/   = undef;\\
    &#64;Afg = qw(\\
      underline_green\\
      underline_yellow\\
      underline_bold_blue\\
      underline_magenta\\
      underline_cyan\\
      underline_red\\
      bold_green\\
      bold_yellow\\
      bold_blue\\
      bold_magenta\\
      bold_cyan\\
      bold_red\\
    );\\
    map { s/_/ /g } &#64;Afg;\\
\\
    sub CoN_modulo {\\
        my ( $pat, $it ) = &#64;_;\\
        $it = $it // 1;\\
        my $it2 = ( int $it ) % ( $#Afg + 1 );\\
        if ( -t STDOUT ) { return colored( $pat, $Afg[$it2], q/on_black/ ); }\\
        else             { return $pat; }\\
    }\\
}\\
my &#64;A  = qw{\!:*};\\
my $i0 = 0;\\
foreach my $s1 (&#64;A) { $_ =~ s/($s1)/ sprintf&quot;%s&quot;, &amp;CoN_modulo($1, $i0) /sixge; $i0++; }\\
'\'
</pre>
</div>
<div class="section" id="usage-hh">
<h2><a class="toc-backref" href="#id20">Usage, hh</a></h2>
<p>As in above picture, please do  this at terminal (to match string1, string2 etc)</p>
<pre class="literal-block">
cat File |hh string1 string2 string3 string4
</pre>
<p>Output would be similar to</p>
<blockquote>
<span class="redbig">string4</span> b0eb22b282 38903c8cea 24db3fc520 <span class="bluebig">string2</span></blockquote>
</div>
</div>
</div>
</body>
</html>
